True this frame if player `player` (1 to 4) has button `b` pressed (the frame it went down) - the same question as btn_pressed, about any player on the link cable. Asking about your own player number reads your own buttons, so one piece of code can serve every player. A player who is not there, or a number that is not a player, is simply false.
Works differently on Game Boy - The Game Boy link cable joins two consoles, not four: players 3 and 4 are never there and read as not pressing anything, and the two consoles decide between themselves which one is player 1, so it can be a different one each time they meet.
Works differently on Game Boy Color - The Game Boy Color link cable joins two consoles, not four: players 3 and 4 are never there and read as not pressing anything, and the two consoles decide between themselves which one is player 1, so it can be a different one each time they meet.
On other consoles this differs: see Side by side and How the consoles differ.
link_button_pressed(player, b) -> bool| Name | Type |
|---|---|
player | int |
b | button |
bool
True on the one frame player player (1 to 4) goes from not holding button b to holding it. It is the question btn_pressed asks, about any player on the link cable. Use it for something that happens once per press: a shot, a jump, a menu choice.
Asking about your own player number gives your own buttons, with no delay. Asking about another player gives what they pressed at their last message, about one to two frames ago.
A very short tap still counts when it arrives in the same frame as the next message: pressed and released can both be true for it. A player who is not there, or a number that is not a player, is false.
if (link_button_pressed(2, BTN_A)) {
x += 1;
}Runs once for each press of A by player 2, however long they keep holding it.
Players are numbered 1 to 4 by where they sit on the cable, and player 1 is the console with the cable’s small purple plug in it. Another player’s buttons arrive about one to two frames after they were pressed (your own are read straight from the buttons, with no delay), so the two consoles never agree to the frame. A player’s buttons are let go of, once, when they disappear, so "while the button is held" never gets stuck if the cable is pulled. A very short tap that arrives in the same frame as the next message still counts: pressed and released can both be true for it.